import { CellRenderer } from "../../../../../fl/controls/listClasses/CellRenderer";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ObjCreate } from "../../common/ObjCreate";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { MarryFriendData } from "../defin/MarryFriendData";
import { PlayerUtil } from "../../common/util/PlayerUtil";
//class MarryNotInviteFriendCell
    
    export  class MarryNotInviteFriendCell extends CellRenderer
    {
        constructor()
        {
            super();
            this.create();
            this.initStyles();
            this.mouseEnabled = true;
            this.mouseChildren = false;
            return;
        }

        /* internal  */initStyles(): void
        {
            this.setStyle("downSkin", GlobalClass.getBitmap("Friend_over"));
            this.setStyle("overSkin", GlobalClass.getBitmap("Friend_over"));
            this.setStyle("upSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("selectedDownSkin", GlobalClass.getBitmap("Friend_over"));
            this.setStyle("selectedOverSkin", GlobalClass.getBitmap("Friend_over"));
            this.setStyle("selectedUpSkin", GlobalClass.getBitmap("Friend_over"));
            return;
        }

        /* internal  */create(): void
        {
            this._tfPlayerName = ObjCreate.createTextField("", 2, 0, 95, 20, this, GlobalStyle.textFormat6);
            this._tfCampName = ObjCreate.createTextField("", 100, 0, 50, 20, this);
            this.addEventListener(flash.events.MouseEvent.CLICK, this.onClick);
            return;
        }

        /* internal  */onClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this._marryFriendData) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.MarryFriendInviteAddToRight, this._marryFriendData.friendName));
            }
            return;
        }

        public /* override */ set label(arg1: string)
        {
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            if (typeof arg1 === "marryfrienddata") 
            {
                this._marryFriendData = arg1 as MarryFriendData;
                this.updateView();
            }
            return;
        }

        /* internal  */updateView(): void
        {
            this._tfPlayerName.text = this._marryFriendData.friendName;
            this._tfCampName.htmlText = PlayerUtil.getCampHtml(this._marryFriendData.camp);
            var loc1=GlobalStyle.textFormatOffline;
            if (this._marryFriendData.isInvited || this._marryFriendData.isAddToRight) 
            {
                this._tfPlayerName.setTextFormat(loc1);
                this._tfCampName.setTextFormat(loc1);
                this.mouseEnabled = false;
            }
            else 
            {
                this._tfPlayerName.setTextFormat(GlobalStyle.textFormat6);
                this._tfCampName.setTextFormat(GlobalStyle.textFormat1);
                this.mouseEnabled = true;
            }
            return;
        }

        /* internal */ /* var */_tfPlayerName: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfCampName: Object /* flash.text.TextField */;

        /* internal */ /* var */_marryFriendData: MarryFriendData;
    }
